import React from "react";
import { Input, Button } from "antd";
class Login extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      admin_mess: {
        name: "",
        password: ""
      }
    };
    this.name_change = this.name_change.bind(this);
    this.pas_change = this.pas_change.bind(this);
    this.login_enter = this.login_enter.bind(this);
  }
  render(h) {
    let LoginData = {};
    return (
      // 登陆页
      <div>
        <div className="center">
          <strong>WDNMD</strong> 
          <Input type="text" onChange={this.name_change} />
          <Input.Password onChange={this.pas_change} />
          <Button onClick={this.login_enter}>登陆</Button>
        </div>
      </div>
    );
  }
  login_enter() {
    let postData = {
      name: this.state.admin_mess.name,
      pas: this.state.admin_mess.password
    };
    if(postData.name=='admin'&&postData.pas=='admin'){
    this.props.history.push({
      pathname:"/main",
      state:{
        id:1
      }
    })
    }
  }
  name_change(e) {
    let admin_mess = this.state.admin_mess;
    admin_mess.name = e.currentTarget.value;
    this.setState({
      admin_mess
    });
  }
  pas_change(e) {
    let admin_mess = this.state.admin_mess;
    admin_mess.password = e.currentTarget.value;
    this.setState({
      admin_mess
    });
  }
  *generClass() {
    yield "WDNMD";
    yield "wdnmd_s";
  }
  componentDidMount() {
    let obj = this.generClass();
  }
}
export default Login;
